/* Flash OS Routines (Automagically Generated)
 * Copyright (c) 2009-2019 ARM Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

static const uint32_t mkv58f_flash_prog_blob[] = {
    0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
    0xb510494a, 0x60084449, 0x5120f24c, 0x81c14848, 0x1128f64d, 0x880181c1, 0x0101f021, 0x48468001,
    0x49442200, 0x60014448, 0x604102c9, 0x60811209, 0x31fff04f, 0x1205e9c0, 0x2020f880, 0xf0006241,
    0x2800f96d, 0x2001d000, 0x2000bd10, 0x4a3b4770, 0x447ab508, 0x92002300, 0x02cff3c1, 0x48364601,
    0xf0004448, 0x2800f960, 0x2001d000, 0x4933bd08, 0x44794831, 0x44483920, 0xf000b508, 0x2800f8d3,
    0x482ed10e, 0x4b2e4478, 0x447b3832, 0x482a9000, 0x492c2208, 0xf0004448, 0x2800f98f, 0x2001d000,
    0x4b26bd08, 0x4601447b, 0x3b524823, 0x5200f44f, 0xf0004448, 0xb508b8eb, 0x46131dc9, 0x0207f021,
    0x4479491e, 0x91003970, 0x481b4601, 0xf0004448, 0x2800f973, 0x2001d000, 0x481bbd08, 0xf4216801,
    0x60013100, 0x20004919, 0x47706008, 0x20004916, 0x3170b570, 0x48146008, 0xf4216801, 0x60013180,
    0x306c4811, 0xf6436800, 0x4d1074ff, 0xf3c03524, 0xf3c0314e, 0xea0403c9, 0x46181241, 0x7680ea42,
    0x1e40602e, 0x1e49d2fa, 0xbd70d2f5, 0x00000004, 0x40052000, 0x40020000, 0x00000008, 0x000000fb,
    0x000003e2, 0x10000408, 0xe000ed14, 0xe000ef50, 0x4604b570, 0x25006800, 0x061b7803, 0x2370d5fc,
    0x20007003, 0x280ce03a, 0xe8dfd236, 0x0a06f000, 0x1a16120e, 0x2a26221e, 0x6826322e, 0x71f37813,
    0x6826e02a, 0x71b37853, 0x6826e026, 0x71737893, 0x6826e022, 0x713378d3, 0x6826e01e, 0x72f37913,
    0x6826e01a, 0x72b37953, 0x6826e016, 0x72737993, 0x6826e012, 0x723379d3, 0x6826e00e, 0x73f37a13,
    0x6826e00a, 0x73b37a53, 0x6826e006, 0x73737a93, 0x6826e002, 0x73337ad3, 0xb2c01c40, 0xd9c24288,
    0x20806821, 0xe0037008, 0x1c416a60, 0x4780d000, 0x78006820, 0xd5f70600, 0x68484909, 0x2000f440,
    0x68206048, 0x06817800, 0x2504d501, 0x06c1e006, 0x2508d501, 0x07c0e002, 0x2510d000, 0xbd704628,
    0x4001f000, 0x2244b508, 0x2100460b, 0x2000f88d, 0x4798466a, 0xb538bd08, 0x078a4614, 0xf44fd002,
    0xbd387080, 0x428b6843, 0x6882d803, 0x428a441a, 0x68c3d80c, 0xd803428b, 0x441a6902, 0xd801428a,
    0xbd382002, 0xf5011ac9, 0xe0000100, 0x22081ac9, 0x2000f88d, 0xf88d0c0a, 0x0a0a2001, 0x2002f88d,
    0x1003f88d, 0x466a2103, 0xbd3847a0, 0x45f8e92d, 0x46984607, 0x20004616, 0x198a687b, 0xd803428b,
    0x441c68bc, 0xd20e4294, 0x428b68fb, 0x693cd803, 0x4294441c, 0x2002d202, 0x85f8e8bd, 0x25001acc,
    0x0400f504, 0x1acce002, 0x5500f44f, 0xf1f5fbb4, 0x4111fb05, 0xf44fb111, 0xe7ed7080, 0xf1f5fbb6,
    0x6111fb05, 0x2001b1a9, 0xf88de7e6, 0x0c20a000, 0x0001f88d, 0xf88d0a20, 0x21030002, 0x466a4643,
    0xf88d4638, 0x47984003, 0xd1d52800, 0x442c1b76, 0xf04fe001, 0x2e000a09, 0xe7cdd1e7, 0x20004601,
    0x61c86108, 0xe92d4770, 0x684641fc, 0x0482eb01, 0x428e9d08, 0x6887d803, 0x428f4437, 0x68c7d80a,
    0xd804428f, 0xc010f8d0, 0x428f4467, 0x2002d802, 0x81fce8bd, 0xd80642a6, 0x44376887, 0xd30242a7,
    0x24041b89, 0x68c6e00a, 0xd90342a6, 0x44376907, 0xd3ec42a7, 0x24041b89, 0x0100f501, 0xf6f4fbb1,
    0x1416fb04, 0xf44fb114, 0xe7e17080, 0xf88d2401, 0x0c0c4000, 0x4001f88d, 0xf88d0a0c, 0xf88d4002,
    0x0a111003, 0x1004f88d, 0xf88d2106, 0x466a2005, 0x3006f88d, 0xe7cb47a8, 0x43fee92d, 0x46074616,
    0x461c2000, 0x8028f8dd, 0x074b198a, 0xf44fd003, 0xe8bd7080, 0x077383fe, 0x2001d001, 0x687be7f9,
    0xd803428b, 0x441d68bd, 0xd20c4295, 0x428b68fb, 0x693dd803, 0x4295441d, 0x2002d201, 0x1acde7e9,
    0x0500f505, 0x1acde02e, 0x2007e02c, 0x0000f88d, 0xf88d0c28, 0x0a280001, 0x0002f88d, 0x5003f88d,
    0xf88d78e0, 0x78a00004, 0x0005f88d, 0xf88d7860, 0x78200006, 0x0007f88d, 0xf88d79e0, 0x79a00008,
    0x0009f88d, 0xf88d7960, 0x7920000a, 0x4643210b, 0x000bf88d, 0x4638466a, 0x28004798, 0x3408d1b9,
    0x3e083508, 0xd1d02e00, 0x0000e7b3, 0xfffffffe, 0xffffffff, 0xfffffffe, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000
};

// Start address of flash
static const uint32_t flash_start = 0x10000000;
// Size of flash
static const uint32_t flash_size = 0x00100000;

static const sector_info_t sectors_info[] = {
    { 0x10000000, 0x00002000 },
};

static const program_target_t flash = {
    0x20000021, // Init
    0x2000006b, // UnInit
    0x2000008f, // EraseChip
    0x200000c3, // EraseSector
    0x200000d7, // ProgramPage
    0x0,        // Verify

    // BKPT : start of blob + 1
    // RSB  : blob start + header + rw data offset
    // RSP  : stack pointer
    {
        0x20000001,
        0x20000498,
        0x20000700
    },

    0x20000000 + 0x00000A00,        // mem buffer location
    0x20000000,                     // location to write prog_blob in target RAM
    sizeof(mkv58f_flash_prog_blob), // prog_blob size
    mkv58f_flash_prog_blob,         // address of prog_blob
    0x00000200                      // ram_to_flash_bytes_to_be_written
};
